package views.accueil;

import java.io.File;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.LayoutStyle.ComponentPlacement;

import main.NotInitializedException;
import tools.ImageFond;
import views.others.AbstractView;
import controllers.AbstractController;

public class OngletAccueilView extends AbstractView
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	PanelAccueilFinances Pfinances;
	PanelAccueilPersonne PPersonnes;
	PanelAccueilProjet PProjets;

	public OngletAccueilView(AbstractController controller) throws NotInitializedException
	{
		super(controller);

		Pfinances = new PanelAccueilFinances();
		PPersonnes = new PanelAccueilPersonne();

		PProjets = new PanelAccueilProjet();
		
		JPanel imgPanel = new JPanel();		
		
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addComponent(PProjets, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
					.addGap(18)
					.addComponent(imgPanel, GroupLayout.PREFERRED_SIZE, 521, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.RELATED)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(PPersonnes, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
						.addComponent(Pfinances, GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE))
					.addContainerGap())
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addComponent(imgPanel, GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
						.addComponent(PProjets, GroupLayout.PREFERRED_SIZE, 278, GroupLayout.PREFERRED_SIZE)
						.addGroup(groupLayout.createSequentialGroup()
							.addComponent(Pfinances, GroupLayout.PREFERRED_SIZE, 53, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addComponent(PPersonnes, GroupLayout.DEFAULT_SIZE, 345, Short.MAX_VALUE)))
					.addContainerGap())
		);
		imgPanel.add(new ImageFond( new ImageIcon("img"+File.separator+"logo.jpg"), imgPanel.getSize()));
		
		setLayout(groupLayout);
		// TODO Auto-generated constructor stub
	}

	public void refresh() throws NotInitializedException
	{
		Pfinances.refresh();
		PPersonnes.refresh();
		PProjets.refresh();
	}
}
